trendify
trendify ¶
Provides top-level imports
DATA_PRODUCTS_FNAME_DEFAULT
module-attribute
¶
Hard-coded file name for storing data products in batch-processed input directories.
ProductGenerator
module-attribute
¶
ProductGenerator = Callable[[Path], ProductList]
Callable method type. Users must provide a ProductGenerator to map over raw data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Workdir holding raw data (Should be one per run from a batch) |
required |
Returns:
| Type | Description |
|---|---|
ProductList
|
List of data products to be sorted and used to produce assets |
ProductList
module-attribute
¶
ProductList = List[SerializeAsAny[InstanceOf[DataProduct]]]
List of serializable [DataProduct][trendify.API.DataProduct] or child classes thereof
Tag
module-attribute
¶
Determines what types can be used to define a tag
AxLine
pydantic-model
¶
Bases: PlottableData2D
Defines a horizontal or vertical line to be drawn on a plot.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
Value at which to draw the line (x-value for vertical, y-value for horizontal) |
orientation |
LineOrientation
|
Whether line should be horizontal or vertical |
pen |
Pen
|
Style and label information for drawing to matplotlib axes |
tags |
Tags
|
Tags to be used for sorting data |
metadata |
dict[str, str]
|
A dictionary of metadata |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"LineOrientation": {
"description": "Defines orientation for axis lines\n\nAttributes:\n HORIZONTAL (LineOrientation): Horizontal line\n VERTICAL (LineOrientation): Vertical line",
"enum": [
"horizontal",
"vertical"
],
"title": "LineOrientation",
"type": "string"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Defines a horizontal or vertical line to be drawn on a plot.\n\nAttributes:\n value (float): Value at which to draw the line (x-value for vertical, y-value for horizontal)\n orientation (LineOrientation): Whether line should be horizontal or vertical\n pen (Pen): Style and label information for drawing to matplotlib axes\n tags (Tags): Tags to be used for sorting data\n metadata (dict[str, str]): A dictionary of metadata",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
},
"value": {
"title": "Value",
"type": "number"
},
"orientation": {
"$ref": "#/$defs/LineOrientation"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "k",
"size": 1.0,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"required": [
"tags",
"value",
"orientation"
],
"title": "AxLine",
"type": "object"
}
Config:
extra:'forbid'
Fields:
-
value(float) -
orientation(LineOrientation) -
pen(Pen)
plot_to_ax ¶
plot_to_ax(ax: Axes)
Plots line to matplotlib axes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
axes to which line should be plotted |
required |
Source code in src/trendify/api/plotting/axline.py
DataProduct
pydantic-model
¶
Bases: BaseModel
Base class for data products to be generated and handled.
Attributes:
| Name | Type | Description |
|---|---|---|
product_type |
str
|
Product type should be the same as the class name. The product type is used to search for products from a [DataProductCollection][trendify.API.DataProductCollection]. |
tags |
Tags
|
Tags to be used for sorting data. |
metadata |
dict[str, str]
|
A dictionary of metadata to be used as a tool tip for mousover in grafana |
Show JSON schema:
{
"additionalProperties": true,
"description": "Base class for data products to be generated and handled.\n\nAttributes:\n product_type (str): Product type should be the same as the class name.\n The product type is used to search for products from a [DataProductCollection][trendify.API.DataProductCollection].\n tags (Tags): Tags to be used for sorting data.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
}
},
"required": [
"tags"
],
"title": "DataProduct",
"type": "object"
}
Config:
extra:'allow'
Fields:
Validators:
-
_remove_computed_fields
product_type
pydantic-field
¶
product_type: str
Returns:
| Type | Description |
|---|---|
str
|
Product type should be the same as the class name. The product type is used to search for products from a [DataProductCollection][trendify.API.DataProductCollection]. |
__init_subclass__ ¶
__init_subclass__(**kwargs: Any) -> None
Registers child subclasses to be able to parse them from JSON file using the [deserialize_child_classes][trendify.API.DataProduct.deserialize_child_classes] method
Source code in src/trendify/api/base/data_product.py
append_to_list ¶
append_to_list(l: List)
Appends self to list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l
|
List
|
list to which |
required |
Returns:
| Type | Description |
|---|---|
Self
|
returns instance of |
deserialize_child_classes
classmethod
¶
deserialize_child_classes(key: str, **kwargs)
Loads json data to pydandic dataclass of whatever DataProduct child time is appropriate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
json key |
required |
kwargs
|
dict
|
json entries stored under given key |
{}
|
Source code in src/trendify/api/base/data_product.py
DataProductCollection
pydantic-model
¶
DataProductCollection(**kwargs: Any)
Bases: BaseModel
A collection of data products.
Use this class to serialize data products to JSON, de-serialized them from JSON, filter the products, etc.
Attributes:
| Name | Type | Description |
|---|---|---|
elements |
ProductList
|
A list of data products. |
Show JSON schema:
{
"$defs": {
"DataProduct": {
"additionalProperties": true,
"description": "Base class for data products to be generated and handled.\n\nAttributes:\n product_type (str): Product type should be the same as the class name.\n The product type is used to search for products from a [DataProductCollection][trendify.API.DataProductCollection].\n tags (Tags): Tags to be used for sorting data.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
}
},
"required": [
"tags"
],
"title": "DataProduct",
"type": "object"
}
},
"description": "A collection of data products.\n\nUse this class to serialize data products to JSON, de-serialized them from JSON, filter the products, etc.\n\nAttributes:\n elements (ProductList): A list of data products.",
"properties": {
"derived_from": {
"anyOf": [
{
"format": "path",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Derived From"
},
"elements": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/DataProduct"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Elements"
}
},
"title": "DataProductCollection",
"type": "object"
}
Fields:
-
derived_from(Path | None) -
elements(ProductList | None)
Source code in src/trendify/api/generator/data_product_collection.py
add_products ¶
add_products(*products: DataProduct)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
products
|
Tuple[DataProduct | ProductList, ...]
|
Products or lists of products to be appended to collection elements. |
()
|
Source code in src/trendify/api/generator/data_product_collection.py
collect_from_all_jsons
classmethod
¶
collect_from_all_jsons(
*dirs: Path, recursive: bool = False, data_products_filename: str | None = "*.json"
)
Loads all products from JSONs in the given list of directories.
If recursive is set to True, the directories will be searched recursively
(this could lead to double counting if you pass in subdirectories of a parent).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirs
|
Tuple[Path, ...]
|
Directories from which to load data product JSON files. |
()
|
recursive
|
bool
|
whether or not to search each of the provided directories recursively for data product json files. |
False
|
Returns:
| Type | Description |
|---|---|
Type[Self] | None
|
Data product collection if JSON files are found. Otherwise, returns None if no product JSON files were found. |
Source code in src/trendify/api/generator/data_product_collection.py
drop_products ¶
Removes products matching tag and/or object_type from collection elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag | None
|
Tag for which data products should be dropped |
None
|
object_type
|
Type | None
|
Type of data product to drop |
None
|
Returns:
| Type | Description |
|---|---|
DataProductCollection
|
A new collection from which matching elements have been dropped. |
Source code in src/trendify/api/generator/data_product_collection.py
from_iterable
classmethod
¶
from_iterable(*products: Tuple[ProductList, ...])
Returns a new instance containing all of the products provided in the *products argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
products
|
Tuple[ProductList, ...]
|
Lists of data products to combine into a collection |
()
|
Returns:
| Type | Description |
|---|---|
cls
|
A data product collection containing all of the provided products in the |
Source code in src/trendify/api/generator/data_product_collection.py
get_products ¶
Returns a new collection containing products matching tag and/or object_type.
Both tag and object_type default to None which matches all products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag | None
|
Tag of data products to be kept. |
None
|
object_type
|
Type | None
|
Type of data product to keep. |
None
|
Returns:
| Type | Description |
|---|---|
DataProductCollection
|
A new collection containing matching elements. |
Source code in src/trendify/api/generator/data_product_collection.py
get_tags ¶
get_tags(data_product_type: Type[DataProduct] | None = None) -> set
Gets the tags related to a given type of DataProduct. Parent classes will match all child class types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_product_type
|
Type[DataProduct] | None
|
type for which you want to get the list of tags |
None
|
Returns:
| Type | Description |
|---|---|
set
|
set of tags applying to the given |
Source code in src/trendify/api/generator/data_product_collection.py
process_collection
classmethod
¶
process_collection(
dir_in: Path, dir_out: Path, no_tables: bool, no_xy_plots: bool, no_histograms: bool, dpi: int
)
Processes collection of elements corresponding to a single tag. This method should be called on a directory containing jsons for which the products have been sorted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_in
|
Path
|
Input directory for loading assets |
required |
dir_out
|
Path
|
Output directory for assets |
required |
no_tables
|
bool
|
Suppresses table asset creation |
required |
no_xy_plots
|
bool
|
Suppresses xy plot asset creation |
required |
no_histograms
|
bool
|
Suppresses histogram asset creation |
required |
dpi
|
int
|
Sets resolution of asset output |
required |
Source code in src/trendify/api/generator/data_product_collection.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
sort_by_tags
classmethod
¶
sort_by_tags(
dirs_in: List[Path], dir_out: Path, data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT
)
Loads the data product JSON files from dirs_in sorts the products.
Sorted products are written to smaller files in a nested directory structure under dir_out.
A nested directory structure is generated according to the data tags.
Resulting product files are named according to the directory from which they were originally loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirs_in
|
List[Path]
|
Directories from which the data product JSON files are to be loaded. |
required |
dir_out
|
Path
|
Directory to which the sorted data products will be written into a nested folder structure generated according to the data tags. |
required |
data_products_fname
|
str
|
Name of data products file |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/generator/data_product_collection.py
sort_by_tags_single_directory
classmethod
¶
sort_by_tags_single_directory(
dir_in: Path, dir_out: Path, data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT
)
Loads the data product JSON files from dir_in and sorts the products.
Sorted products are written to smaller files in a nested directory structure under dir_out.
A nested directory structure is generated according to the data tags.
Resulting product files are named according to the directory from which they were originally loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_in
|
List[Path]
|
Directories from which the data product JSON files are to be loaded. |
required |
dir_out
|
Path
|
Directory to which the sorted data products will be written into a nested folder structure generated according to the data tags. |
required |
data_products_fname
|
str
|
Name of data products file |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/generator/data_product_collection.py
union
classmethod
¶
union(*collections: DataProductCollection)
Aggregates all of the products from multiple collections into a new larger collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collections
|
Tuple[DataProductCollection, ...]
|
Data product collections for which the products should be combined into a new collection. |
()
|
Returns:
| Type | Description |
|---|---|
Type[Self]
|
A new data product collection containing all products from
the provided |
Source code in src/trendify/api/generator/data_product_collection.py
DataProductGenerator ¶
DataProductGenerator(processor: ProductGenerator)
A wrapper for saving the data products generated by a user defined function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processor
|
ProductGenerator
|
A callable that receives a working directory and returns a list of data products. |
required |
Source code in src/trendify/api/generator/data_product_generator.py
process_and_save ¶
process_and_save(workdir: Path, data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT)
Runs the user-defined processor method stored at instantiation.
Saves the returned products to a JSON file in the same directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workdir
|
Path
|
working directory on which to run the processor method. |
required |
data_products_fname
|
str
|
Name of data products file |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/generator/data_product_generator.py
Format2D
pydantic-model
¶
Bases: HashableBase
Formatting data for matplotlib figure and axes
Attributes:
| Name | Type | Description |
|---|---|---|
title_fig |
Optional[str]
|
Sets figure title |
legend |
Optional[Legend]
|
Sets legend style |
title_ax |
Optional[str]
|
Sets axis title |
label_x |
Optional[str]
|
Sets x-axis label |
label_y |
Optional[str]
|
Sets y-axis label |
lim_x_min |
float | None
|
Sets x-axis lower bound |
lim_x_max |
float | None
|
Sets x-axis upper bound |
lim_y_min |
float | None
|
Sets y-axis lower bound |
lim_y_max |
float | None
|
Sets y-axis upper bound |
grid |
Grid | None
|
Sets the grid |
scale_x |
AxisScale
|
Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale] |
scale_y |
AxisScale
|
Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale] |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
}
Config:
extra:'forbid'
Fields:
-
title_fig(Optional[str] | None) -
legend(Optional[Legend]) -
title_ax(Optional[str] | None) -
label_x(Optional[str] | None) -
label_y(Optional[str] | None) -
lim_x_min(float | None) -
lim_x_max(float | None) -
lim_y_min(float | None) -
lim_y_max(float | None) -
grid(Grid | None) -
scale_x(AxisScale) -
scale_y(AxisScale)
union_from_iterable
classmethod
¶
Gets the most inclusive format object (in terms of limits) from a list of Format2D objects.
Requires that the label and title fields are identical for all format objects in the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format2ds
|
Iterable[Format2D]
|
Iterable of |
required |
Returns:
| Type | Description |
|---|---|
Format2D
|
Single format object from list of objects. |
Source code in src/trendify/api/formats/format2d.py
Grid
pydantic-model
¶
Bases: HashableBase
Container for major and minor grid line configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
major |
GridAxis
|
Configuration for major grid lines. |
minor |
GridAxis
|
Configuration for minor grid lines. |
enable_minor_ticks |
bool
|
Whether to enable minor ticks on the axes. |
Show JSON schema:
{
"$defs": {
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
}
Config:
extra:'forbid'
Fields:
from_theme
classmethod
¶
from_theme(name: GridTheme) -> Grid
Predefined themes for common grid styles.
Source code in src/trendify/api/styling/grid.py
union_from_iterable
classmethod
¶
Gets the most inclusive grid format from a list of Grid objects. Requires that all GridAxis fields (major/minor) are consistent across the objects.
Source code in src/trendify/api/styling/grid.py
GridAxis
pydantic-model
¶
Bases: HashableBase
Controls styling and visibility for one type of grid (major or minor).
Attributes:
| Name | Type | Description |
|---|---|---|
show |
bool
|
Whether to display this grid axis. |
pen |
Pen
|
Style and label information for drawing to matplotlib axes. |
Show JSON schema:
{
"$defs": {
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
}
Config:
extra:'forbid'
Fields:
HashableBase
pydantic-model
¶
Bases: BaseModel
Defines a base for hashable pydantic data classes so that they can be reduced to a minimal set through type-casting.
Show JSON schema:
HistogramEntry
pydantic-model
¶
Bases: PlottableData2D
Use this class to specify a value to be collected into a matplotlib histogram.
Attributes:
| Name | Type | Description |
|---|---|---|
tags |
Tags
|
Tags used to sort data products |
value |
float | str
|
Value to be binned |
style |
HistogramStyle
|
Style of histogram display |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"HistogramStyle": {
"description": "Label and style data for generating histogram bars\n\nAttributes:\n color (str): Color of bars\n label (str|None): Legend entry\n histtype (str): Histogram type corresponding to matplotlib argument of same name\n alpha_edge (float): Opacity of bar edge\n alpha_face (float): Opacity of bar face\n linewidth (float): Line width of bar outline\n bins (int | list[int] | Tuple[int] | NDArray[Shape[\"*\"], int] | None): Number of bins (see [matplotlib docs][matplotlib.pyplot.hist])",
"properties": {
"color": {
"default": "k",
"title": "Color",
"type": "string"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
},
"histtype": {
"default": "stepfilled",
"title": "Histtype",
"type": "string"
},
"alpha_edge": {
"default": 0,
"title": "Alpha Edge",
"type": "number"
},
"alpha_face": {
"default": 0.3,
"title": "Alpha Face",
"type": "number"
},
"linewidth": {
"default": 2,
"title": "Linewidth",
"type": "number"
},
"bins": {
"anyOf": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
},
{
"maxItems": 1,
"minItems": 1,
"prefixItems": [
{
"type": "integer"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bins"
}
},
"title": "HistogramStyle",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Use this class to specify a value to be collected into a matplotlib histogram.\n\nAttributes:\n tags (Tags): Tags used to sort data products\n value (float | str): Value to be binned\n style (HistogramStyle): Style of histogram display",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
},
"value": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Value"
},
"style": {
"anyOf": [
{
"$ref": "#/$defs/HistogramStyle"
},
{
"type": "null"
}
]
}
},
"required": [
"tags",
"value"
],
"title": "HistogramEntry",
"type": "object"
}
Config:
extra:'forbid'
Fields:
-
value(float | str) -
tags(Tags) -
style(HistogramStyle | None)
HistogramStyle
pydantic-model
¶
Bases: HashableBase
Label and style data for generating histogram bars
Attributes:
| Name | Type | Description |
|---|---|---|
color |
str
|
Color of bars |
label |
str | None
|
Legend entry |
histtype |
str
|
Histogram type corresponding to matplotlib argument of same name |
alpha_edge |
float
|
Opacity of bar edge |
alpha_face |
float
|
Opacity of bar face |
linewidth |
float
|
Line width of bar outline |
bins |
int | list[int] | Tuple[int] | NDArray[Shape['*'], int] | None
|
Number of bins (see matplotlib docs) |
Show JSON schema:
{
"description": "Label and style data for generating histogram bars\n\nAttributes:\n color (str): Color of bars\n label (str|None): Legend entry\n histtype (str): Histogram type corresponding to matplotlib argument of same name\n alpha_edge (float): Opacity of bar edge\n alpha_face (float): Opacity of bar face\n linewidth (float): Line width of bar outline\n bins (int | list[int] | Tuple[int] | NDArray[Shape[\"*\"], int] | None): Number of bins (see [matplotlib docs][matplotlib.pyplot.hist])",
"properties": {
"color": {
"default": "k",
"title": "Color",
"type": "string"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
},
"histtype": {
"default": "stepfilled",
"title": "Histtype",
"type": "string"
},
"alpha_edge": {
"default": 0,
"title": "Alpha Edge",
"type": "number"
},
"alpha_face": {
"default": 0.3,
"title": "Alpha Face",
"type": "number"
},
"linewidth": {
"default": 2,
"title": "Linewidth",
"type": "number"
},
"bins": {
"anyOf": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
},
{
"maxItems": 1,
"minItems": 1,
"prefixItems": [
{
"type": "integer"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bins"
}
},
"title": "HistogramStyle",
"type": "object"
}
Fields:
Histogrammer ¶
Class for loading data products and histogramming the [HistogramEntry][trendify.API.HistogramEntry]s
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dirs
|
List[Path]
|
Directories from which the data products are to be loaded. |
required |
out_dir
|
Path
|
Directory to which the generated histogram will be stored |
required |
dpi
|
int
|
resolution of plot |
required |
Source code in src/trendify/api/generator/histogrammer.py
handle_histogram_entries
classmethod
¶
handle_histogram_entries(
tag: Tag,
histogram_entries: List[HistogramEntry],
dir_out: Path,
dpi: int,
saf: SingleAxisFigure | None = None,
) -> SingleAxisFigure
Histograms the provided entries. Formats and saves the figure. Closes the figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
Tag used to filter the loaded data products |
required |
histogram_entries
|
List[HistogramEntry]
|
A list of [ |
required |
dir_out
|
Path
|
Directory to which the generated histogram will be stored |
required |
dpi
|
int
|
resolution of plot |
required |
Source code in src/trendify/api/generator/histogrammer.py
Legend
pydantic-model
¶
Bases: HashableBase
Configuration container for Matplotlib legend styling and placement.
The Legend class controls the appearance and position of the plot legend.
Placement is governed by a combination of the loc and bbox_to_anchor
parameters, mirroring Matplotlib's Axes.legend().
Attributes:
| Name | Type | Description |
|---|---|---|
visible |
bool
|
Whether the legend should be displayed. Defaults to True. |
title |
str | None
|
Title displayed above the legend entries. |
framealpha |
float
|
Opacity of the legend background. 1 = fully opaque, 0 = fully transparent. |
loc |
LegendLocation
|
Anchor point for the legend (e.g., upper right, lower left). See |
ncol |
int
|
Number of columns to arrange legend entries into. |
fancybox |
bool
|
Whether to draw a rounded (True) or square (False) legend frame. |
edgecolor |
str
|
Color of the legend frame border. Default is "black". |
bbox_to_anchor |
tuple[float, float] | None
|
Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using Good starter values for common placements:
|
Show JSON schema:
{
"$defs": {
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
}
},
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
}
Fields:
-
visible(bool) -
title(str | None) -
framealpha(float) -
loc(LegendLocation) -
ncol(int) -
fancybox(bool) -
edgecolor(str) -
bbox_to_anchor(tuple[float, float] | None)
LineOrientation ¶
Bases: Enum
Defines orientation for axis lines
Attributes:
| Name | Type | Description |
|---|---|---|
HORIZONTAL |
LineOrientation
|
Horizontal line |
VERTICAL |
LineOrientation
|
Vertical line |
Marker
pydantic-model
¶
Bases: HashableBase
Defines marker for scattering to matplotlib
Attributes:
| Name | Type | Description |
|---|---|---|
color |
str
|
Color of line |
size |
float
|
Line width |
alpha |
float
|
Opacity from 0 to 1 (inclusive) |
zorder |
float
|
Prioritization |
label |
Union[str, None]
|
Legend label |
symbol |
str
|
Matplotlib symbol string |
Show JSON schema:
{
"additionalProperties": false,
"description": "Defines marker for scattering to matplotlib\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n zorder (float): Prioritization\n label (Union[str, None]): Legend label\n symbol (str): Matplotlib symbol string",
"properties": {
"color": {
"default": "k",
"title": "Color",
"type": "string"
},
"size": {
"default": 5,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
},
"symbol": {
"default": ".",
"title": "Symbol",
"type": "string"
}
},
"title": "Marker",
"type": "object"
}
Config:
extra:'forbid'
Fields:
as_scatter_plot_kwargs ¶
Returns:
| Type | Description |
|---|---|
dict
|
dictionary of |
Source code in src/trendify/api/styling/marker.py
from_pen
classmethod
¶
Converts Pen to marker with the option to specify a symbol
Pen
pydantic-model
¶
Bases: HashableBase
Defines the pen drawing to matplotlib.
Attributes:
| Name | Type | Description |
|---|---|---|
color |
str
|
Color of line |
size |
float
|
Line width |
alpha |
float
|
Opacity from 0 to 1 (inclusive) |
linestyle |
Union[str, Tuple[int, Tuple[int, ...]]]
|
Linestyle to plot. Supports |
zorder |
float
|
Prioritization |
label |
Union[str, None]
|
Legend label |
Show JSON schema:
{
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
Config:
extra:'forbid'
Fields:
-
color(Tuple[float, float, float] | Tuple[float, float, float, float] | str) -
size(float) -
alpha(float) -
zorder(float) -
linestyle(Union[str, Tuple[int, Tuple[int, ...]]]) -
label(Union[str, None])
as_scatter_plot_kwargs ¶
Returns kwargs dictionary for passing to matplotlib plot method
Source code in src/trendify/api/base/pen.py
PlottableData2D
pydantic-model
¶
Bases: DataProduct
Base class for children of DataProduct to be plotted ax xy data on a 2D plot
Attributes:
| Name | Type | Description |
|---|---|---|
format2d |
Format2D | None
|
Format to apply to plot |
tags |
Tags
|
Tags to be used for sorting data. |
metadata |
dict[str, str]
|
A dictionary of metadata to be used as a tool tip for mousover in grafana |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": true,
"description": "Base class for children of DataProduct to be plotted ax xy data on a 2D plot\n\nAttributes:\n format2d (Format2D|None): Format to apply to plot\n tags (Tags): Tags to be used for sorting data.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"tags"
],
"title": "PlottableData2D",
"type": "object"
}
Fields:
-
format2d(Format2D | None)
Point2D
pydantic-model
¶
Bases: XYData
Defines a point to be scattered onto xy plot.
Attributes:
| Name | Type | Description |
|---|---|---|
tags |
Tags
|
Tags to be used for sorting data. |
x |
float | str
|
X value for the point. |
y |
float | str
|
Y value for the point. |
marker |
Marker | None
|
Style and label information for scattering points to matplotlib axes. Only the label information is used in Grafana. Eventually style information will be used in grafana. |
metadata |
dict[str, str]
|
A dictionary of metadata to be used as a tool tip for mousover in grafana |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Marker": {
"additionalProperties": false,
"description": "Defines marker for scattering to matplotlib\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n zorder (float): Prioritization\n label (Union[str, None]): Legend label\n symbol (str): Matplotlib symbol string",
"properties": {
"color": {
"default": "k",
"title": "Color",
"type": "string"
},
"size": {
"default": 5,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
},
"symbol": {
"default": ".",
"title": "Symbol",
"type": "string"
}
},
"title": "Marker",
"type": "object"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": false,
"description": "Defines a point to be scattered onto xy plot.\n\nAttributes:\n tags (Tags): Tags to be used for sorting data.\n x (float | str): X value for the point.\n y (float | str): Y value for the point.\n marker (Marker | None): Style and label information for scattering points to matplotlib axes.\n Only the label information is used in Grafana.\n Eventually style information will be used in grafana.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
},
"x": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "X"
},
"y": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Y"
},
"marker": {
"anyOf": [
{
"$ref": "#/$defs/Marker"
},
{
"type": "null"
}
],
"default": {
"color": "k",
"size": 5.0,
"alpha": 1.0,
"zorder": 0.0,
"label": null,
"symbol": "."
}
}
},
"required": [
"tags",
"x",
"y"
],
"title": "Point2D",
"type": "object"
}
Config:
extra:'forbid'
Fields:
ProductType ¶
SingleAxisFigure
dataclass
¶
Data class storing a matlab figure and axis. The stored tag data in this class is so-far unused.
Attributes:
| Name | Type | Description |
|---|---|---|
ax |
Axes
|
Matplotlib axis to which data will be plotted |
fig |
Figure
|
Matplotlib figure. |
tag |
Tag
|
Figure tag. Not yet used. |
__del__ ¶
apply_format ¶
apply_format(format2d: Format2D)
Applies format to figure and axes labels and limits
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format2d
|
Format2D
|
format information to apply to the single axis figure |
required |
Source code in src/trendify/api/plotting/plotting.py
new
classmethod
¶
new(tag: Tag)
Creates new figure and axis. Returns new instance of this class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
tag (not yet used) |
required |
Returns:
| Type | Description |
|---|---|
Type[Self]
|
New single axis figure |
Source code in src/trendify/api/plotting/plotting.py
savefig ¶
Wrapper on matplotlib savefig method. Saves figure to given path with given dpi resolution.
Returns:
| Type | Description |
|---|---|
Self
|
Returns self |
Source code in src/trendify/api/plotting/plotting.py
TableBuilder ¶
Builds tables (melted, pivot, and stats) for histogramming and including in a report or Grafana dashboard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dirs
|
List[Path]
|
directories from which to load data products |
required |
out_dir
|
Path
|
directory in which tables should be saved |
required |
Source code in src/trendify/api/generator/table_builder.py
get_stats_table
classmethod
¶
get_stats_table(df: DataFrame)
Computes multiple statistics for each column
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame for which the column statistics are to be calculated. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe having statistics (column headers) for each of the columns
of the input |
Source code in src/trendify/api/generator/table_builder.py
load_table ¶
load_table(tag: Tag, data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT)
Collects table entries from JSON files corresponding to given tag and processes them.
Saves CSV files for the melted data frame, pivot dataframe, and pivot dataframe stats.
File names will all use the tag with different suffixes
'tag_melted.csv', 'tag_pivot.csv', 'name_stats.csv'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
product tag for which to collect and process. |
required |
Source code in src/trendify/api/generator/table_builder.py
process_table_entries
classmethod
¶
process_table_entries(tag: Tag, table_entries: List[TableEntry], out_dir: Path)
Saves CSV files for the melted data frame, pivot dataframe, and pivot dataframe stats.
File names will all use the tag with different suffixes
'tag_melted.csv', 'tag_pivot.csv', 'name_stats.csv'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
product tag for which to collect and process. |
required |
table_entries
|
List[TableEntry]
|
List of table entries |
required |
out_dir
|
Path
|
Directory to which table CSV files should be saved |
required |
Source code in src/trendify/api/generator/table_builder.py
TableEntry
pydantic-model
¶
Bases: DataProduct
Defines an entry to be collected into a table.
Collected table entries will be printed in three forms when possible: melted, pivot (when possible), and stats (on pivot columns, when possible).
Attributes:
| Name | Type | Description |
|---|---|---|
tags |
Tags
|
Tags used to sort data products |
row |
float | str
|
Row Label |
col |
float | str
|
Column Label |
value |
float | str
|
Value |
unit |
str | None
|
Units for value |
metadata |
dict[str, str]
|
A dictionary of metadata to be used as a tool tip for mousover in grafana |
Show JSON schema:
{
"additionalProperties": false,
"description": "Defines an entry to be collected into a table.\n\nCollected table entries will be printed in three forms when possible: melted, pivot (when possible), and stats (on pivot columns, when possible).\n\nAttributes:\n tags (Tags): Tags used to sort data products\n row (float | str): Row Label\n col (float | str): Column Label\n value (float | str): Value\n unit (str | None): Units for value\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"row": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Row"
},
"col": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Col"
},
"value": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
},
{
"type": "boolean"
}
],
"title": "Value"
},
"unit": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Unit"
}
},
"required": [
"tags",
"row",
"col",
"value"
],
"title": "TableEntry",
"type": "object"
}
Config:
extra:'forbid'
Fields:
get_entry_dict ¶
Returns a dictionary of entries to be used in creating a table.
Returns:
| Type | Description |
|---|---|
dict[str, str | float]
|
Dictionary of entries to be used in creating a melted DataFrame |
Source code in src/trendify/api/formats/table.py
load_and_pivot
classmethod
¶
load_and_pivot(path: Path)
Loads melted table from csv and pivots to wide form.
csv should have columns named 'row', 'col', and 'value'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
path to CSV file |
required |
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
Pivoted data frame or elese |
Source code in src/trendify/api/formats/table.py
pivot_table
classmethod
¶
pivot_table(melted: DataFrame)
Attempts to pivot melted row, col, value DataFrame into a wide form DataFrame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
melted
|
DataFrame
|
Melted data frame having columns named |
required |
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
pivoted DataFrame if pivot works else |
Source code in src/trendify/api/formats/table.py
Trace2D
pydantic-model
¶
Bases: XYData
A collection of points comprising a trace. Use the [Trace2D.from_xy][trendify.API.Trace2D.from_xy] constructor.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
List[Point2D]
|
List of points. Usually the points would have null values
for |
pen |
Pen
|
Style and label information for drawing to matplotlib axes. Only the label information is used in Grafana. Eventually style information will be used in grafana. |
tags |
Tags
|
Tags to be used for sorting data. |
metadata |
dict[str, str]
|
A dictionary of metadata to be used as a tool tip for mousover in grafana |
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Marker": {
"additionalProperties": false,
"description": "Defines marker for scattering to matplotlib\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n zorder (float): Prioritization\n label (Union[str, None]): Legend label\n symbol (str): Matplotlib symbol string",
"properties": {
"color": {
"default": "k",
"title": "Color",
"type": "string"
},
"size": {
"default": 5,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
},
"symbol": {
"default": ".",
"title": "Symbol",
"type": "string"
}
},
"title": "Marker",
"type": "object"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
},
"Point2D": {
"additionalProperties": false,
"description": "Defines a point to be scattered onto xy plot.\n\nAttributes:\n tags (Tags): Tags to be used for sorting data.\n x (float | str): X value for the point.\n y (float | str): Y value for the point.\n marker (Marker | None): Style and label information for scattering points to matplotlib axes.\n Only the label information is used in Grafana.\n Eventually style information will be used in grafana.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
},
"x": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "X"
},
"y": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Y"
},
"marker": {
"anyOf": [
{
"$ref": "#/$defs/Marker"
},
{
"type": "null"
}
],
"default": {
"color": "k",
"size": 5.0,
"alpha": 1.0,
"zorder": 0.0,
"label": null,
"symbol": "."
}
}
},
"required": [
"tags",
"x",
"y"
],
"title": "Point2D",
"type": "object"
}
},
"additionalProperties": false,
"description": "A collection of points comprising a trace.\nUse the [Trace2D.from_xy][trendify.API.Trace2D.from_xy] constructor.\n\nAttributes:\n points (List[Point2D]): List of points. Usually the points would have null values\n for `marker` and `format2d` fields to save space.\n pen (Pen): Style and label information for drawing to matplotlib axes.\n Only the label information is used in Grafana.\n Eventually style information will be used in grafana.\n tags (Tags): Tags to be used for sorting data.\n metadata (dict[str, str]): A dictionary of metadata to be used as a tool tip for mousover in grafana",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
},
"points": {
"items": {
"$ref": "#/$defs/Point2D"
},
"title": "Points",
"type": "array"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "k",
"size": 1.0,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"required": [
"tags",
"points"
],
"title": "Trace2D",
"type": "object"
}
Config:
extra:'forbid'
Fields:
x
pydantic-field
¶
y
pydantic-field
¶
from_xy
classmethod
¶
from_xy(
tags: Tags,
x: NDArray[Shape["*"], float],
y: NDArray[Shape["*"], float],
pen: Pen = Pen(),
format2d: Format2D | None = None,
)
Creates a list of [Point2D][trendify.API.Point2D]s from xy data and returns a new [Trace2D][trendify.API.Trace2D] product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Tags
|
Tags used to sort data products |
required |
x
|
NDArray[Shape['*'], float]
|
x values |
required |
y
|
NDArray[Shape['*'], float]
|
y values |
required |
pen
|
Pen
|
Style and label for trace |
Pen()
|
format2d
|
Format2D | None
|
Format to apply to plot |
None
|
Source code in src/trendify/api/plotting/trace.py
plot_to_ax ¶
plot_to_ax(ax: Axes)
Plots xy data from trace to a matplotlib axes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
axes to which xy data should be plotted |
required |
propagate_format2d_and_pen ¶
propagate_format2d_and_pen(marker_symbol: str = '.') -> None
Propagates format and style info to all self.points (in-place).
I thought this would be useful for grafana before I learned better methods for propagating the data.
It still may end up being useful if my plotting method changes. Keeping for potential future use case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker_symbol
|
str
|
Valid matplotlib marker symbol |
'.'
|
Source code in src/trendify/api/plotting/trace.py
XYData
pydantic-model
¶
Bases: PlottableData2D
Base class for children of DataProduct to be plotted ax xy data on a 2D plot
Show JSON schema:
{
"$defs": {
"AxisScale": {
"enum": [
"linear",
"log"
],
"title": "AxisScale",
"type": "string"
},
"Format2D": {
"additionalProperties": false,
"description": "Formatting data for matplotlib figure and axes\n\nAttributes:\n title_fig (Optional[str]): Sets [figure title][matplotlib.figure.Figure.suptitle]\n legend (Optional[Legend]): Sets [legend style][trendify.api.styling.legend.Legend]\n title_ax (Optional[str]): Sets [axis title][matplotlib.axes.Axes.set_title]\n label_x (Optional[str]): Sets [x-axis label][matplotlib.axes.Axes.set_xlabel]\n label_y (Optional[str]): Sets [y-axis label][matplotlib.axes.Axes.set_ylabel]\n lim_x_min (float | None): Sets [x-axis lower bound][matplotlib.axes.Axes.set_xlim]\n lim_x_max (float | None): Sets [x-axis upper bound][matplotlib.axes.Axes.set_xlim]\n lim_y_min (float | None): Sets [y-axis lower bound][matplotlib.axes.Axes.set_ylim]\n lim_y_max (float | None): Sets [y-axis upper bound][matplotlib.axes.Axes.set_ylim]\n grid (Grid | None): Sets the [grid][matplotlib.pyplot.grid]\n scale_x (AxisScale): Sets the x axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]\n scale_y (AxisScale): Sets the y axis scale to an option from [AxisScale][trendify.api.formats.format2d.AxisScale]",
"properties": {
"title_fig": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Fig"
},
"legend": {
"anyOf": [
{
"$ref": "#/$defs/Legend"
},
{
"type": "null"
}
],
"default": {
"visible": true,
"title": null,
"framealpha": 1.0,
"loc": "best",
"ncol": 1,
"fancybox": true,
"edgecolor": "black",
"bbox_to_anchor": null
}
},
"title_ax": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title Ax"
},
"label_x": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label X"
},
"label_y": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label Y"
},
"lim_x_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Min"
},
"lim_x_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim X Max"
},
"lim_y_min": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Min"
},
"lim_y_max": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Lim Y Max"
},
"grid": {
"anyOf": [
{
"$ref": "#/$defs/Grid"
},
{
"type": "null"
}
],
"default": null
},
"scale_x": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
},
"scale_y": {
"$ref": "#/$defs/AxisScale",
"default": "linear"
}
},
"title": "Format2D",
"type": "object"
},
"Grid": {
"additionalProperties": false,
"description": "Container for major and minor grid line configuration.\n\nAttributes:\n major (GridAxis): Configuration for major grid lines.\n minor (GridAxis): Configuration for minor grid lines.\n enable_minor_ticks (bool): Whether to enable minor ticks on the axes.",
"properties": {
"major": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"minor": {
"$ref": "#/$defs/GridAxis",
"default": {
"show": false,
"pen": {
"alpha": 1.0,
"color": "gray",
"label": null,
"linestyle": "-",
"size": 0.75,
"zorder": 0.0
}
}
},
"enable_minor_ticks": {
"default": false,
"title": "Enable Minor Ticks",
"type": "boolean"
},
"zorder": {
"default": -1,
"title": "Zorder",
"type": "number"
}
},
"title": "Grid",
"type": "object"
},
"GridAxis": {
"additionalProperties": false,
"description": "Controls styling and visibility for one type of grid (major or minor).\n\nAttributes:\n show (bool): Whether to display this grid axis.\n pen (Pen): Style and label information for drawing to matplotlib axes.",
"properties": {
"show": {
"default": false,
"title": "Show",
"type": "boolean"
},
"pen": {
"$ref": "#/$defs/Pen",
"default": {
"color": "gray",
"size": 0.75,
"alpha": 1.0,
"zorder": 0.0,
"linestyle": "-",
"label": null
}
}
},
"title": "GridAxis",
"type": "object"
},
"Legend": {
"description": "Configuration container for Matplotlib legend styling and placement.\n\nThe `Legend` class controls the appearance and position of the plot legend.\nPlacement is governed by a combination of the `loc` and `bbox_to_anchor`\nparameters, mirroring Matplotlib's `Axes.legend()`.\n\nAttributes:\n visible (bool): Whether the legend should be displayed. Defaults to True.\n title (str | None): Title displayed above the legend entries.\n framealpha (float): Opacity of the legend background. 1 = fully opaque, 0 = fully transparent.\n loc (LegendLocation): Anchor point for the legend (e.g., upper right, lower left). See `LegendLocation` enum for options.\n ncol (int): Number of columns to arrange legend entries into.\n fancybox (bool): Whether to draw a rounded (True) or square (False) legend frame.\n edgecolor (str): Color of the legend frame border. Default is \"black\".\n bbox_to_anchor (tuple[float, float] | None): Offset position of the legend in figure or axes coordinates. If None, the legend is placed inside the axes using `loc`.\n\n Good starter values for common placements:\n\n - **Inside (default)**:\n ```python\n bbox_to_anchor=None\n ```\n - **Outside right**:\n ```python\n loc=LegendLocation.CENTER_LEFT\n bbox_to_anchor=(1.02, 0.5)\n ```\n - **Outside left**:\n ```python\n loc=LegendLocation.CENTER_RIGHT\n bbox_to_anchor=(-0.02, 0.5)\n ```\n - **Outside top**:\n ```python\n loc=LegendLocation.LOWER_CENTER\n bbox_to_anchor=(0.5, 1.02)\n ```\n - **Outside bottom**:\n ```python\n loc=LegendLocation.UPPER_CENTER\n bbox_to_anchor=(0.5, -0.02)\n ```",
"properties": {
"visible": {
"default": true,
"title": "Visible",
"type": "boolean"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"framealpha": {
"default": 1,
"title": "Framealpha",
"type": "number"
},
"loc": {
"$ref": "#/$defs/LegendLocation",
"default": "best"
},
"ncol": {
"default": 1,
"title": "Ncol",
"type": "integer"
},
"fancybox": {
"default": true,
"title": "Fancybox",
"type": "boolean"
},
"edgecolor": {
"default": "black",
"title": "Edgecolor",
"type": "string"
},
"bbox_to_anchor": {
"anyOf": [
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Bbox To Anchor"
}
},
"title": "Legend",
"type": "object"
},
"LegendLocation": {
"enum": [
"best",
"upper right",
"upper left",
"lower left",
"lower right",
"right",
"center left",
"center right",
"lower center",
"upper center",
"center"
],
"title": "LegendLocation",
"type": "string"
},
"Pen": {
"additionalProperties": false,
"description": "Defines the pen drawing to matplotlib.\n\nAttributes:\n color (str): Color of line\n size (float): Line width\n alpha (float): Opacity from 0 to 1 (inclusive)\n linestyle (Union[str, Tuple[int, Tuple[int, ...]]]): Linestyle to plot. Supports `str` or `tuple` definition ([matplotlib documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)).\n zorder (float): Prioritization\n label (Union[str, None]): Legend label",
"properties": {
"color": {
"anyOf": [
{
"maxItems": 3,
"minItems": 3,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"maxItems": 4,
"minItems": 4,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
{
"type": "string"
}
],
"default": "k",
"title": "Color"
},
"size": {
"default": 1,
"title": "Size",
"type": "number"
},
"alpha": {
"default": 1,
"title": "Alpha",
"type": "number"
},
"zorder": {
"default": 0,
"title": "Zorder",
"type": "number"
},
"linestyle": {
"anyOf": [
{
"type": "string"
},
{
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "integer"
},
{
"items": {
"type": "integer"
},
"type": "array"
}
],
"type": "array"
}
],
"default": "-",
"title": "Linestyle"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Label"
}
},
"title": "Pen",
"type": "object"
}
},
"additionalProperties": true,
"description": "Base class for children of DataProduct to be plotted ax xy data on a 2D plot",
"properties": {
"tags": {
"items": {
"anyOf": []
},
"title": "Tags",
"type": "array"
},
"metadata": {
"additionalProperties": {
"type": "string"
},
"default": {},
"title": "Metadata",
"type": "object"
},
"format2d": {
"anyOf": [
{
"$ref": "#/$defs/Format2D"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"tags"
],
"title": "XYData",
"type": "object"
}
XYDataPlotter ¶
Plots xy data from user-specified directories to a single axis figure
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dirs
|
List[Path]
|
Directories in which to search for data products from JSON files |
required |
out_dir
|
Path
|
directory to which figure will be output |
required |
dpi
|
int
|
Saved image resolution |
500
|
Source code in src/trendify/api/generator/xy_data_plotter.py
handle_points_and_traces
classmethod
¶
handle_points_and_traces(
tag: Tag,
points: List[Point2D],
traces: List[Trace2D],
axlines: List[AxLine],
dir_out: Path,
dpi: int,
saf: SingleAxisFigure | None = None,
)
Plots points, traces, and axlines, formats figure, saves figure, and closes matplotlinb figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
Tag corresponding to the provided points and traces |
required |
points
|
List[Point2D]
|
Points to be scattered |
required |
traces
|
List[Trace2D]
|
List of traces to be plotted |
required |
axlines
|
List[AxLine]
|
List of axis lines to be plotted |
required |
dir_out
|
Path
|
directory to output the plot |
required |
dpi
|
int
|
resolution of plot |
required |
Source code in src/trendify/api/generator/xy_data_plotter.py
plot ¶
plot(tag: Tag, data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT)
- Collects data from json files in stored
self.in_dirs, - plots the relevant products,
- applies labels and formatting,
- saves the figure
- closes matplotlib figure
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
Tag
|
data tag for which products are to be collected and plotted. |
required |
data_products_fname
|
str
|
Data products file name |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/generator/xy_data_plotter.py
flatten ¶
flatten(obj: Iterable)
Recursively flattens iterable up to a point (leaves str, bytes, and DataProduct unflattened)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Iterable
|
Object to be flattened |
required |
Returns:
| Type | Description |
|---|---|
Iterable
|
Flattned iterable |
Source code in src/trendify/api/generator/data_product_collection.py
get_data_products ¶
get_data_products(
analysis: str = "workdir.products", tag: str = "trace_plots", product_type: str = "DataProduct"
)
Traces
parse-json | project "elements" | extend "label"="pen.label" | mv-expand "points" | extend "x"="points.x", "y"="points.y" | project "label", "x", "y" | pivot sum("y"), "x", "label" | project "label", "x", "y"
Source code in src/trendify/server.py
make_include_files ¶
make_include_files(
root_dir: Path,
local_server_path: str | Path | None = None,
mkdocs_include_dir: str | Path | None = None,
heading_level: int | None = None,
)
Makes nested include files for inclusion into an MkDocs site.
Note
I recommend to create a Grafana panel and link to that from the MkDocs site instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
Path
|
Directory for which the include files should be recursively generated |
required |
local_server_path
|
str | Path | None
|
What should the beginning of the path look like?
Use |
None
|
mkdocs_include_dir
|
str | Path | None
|
Path to be used for mkdocs includes.
This path should correspond to includ dir in |
None
|
Note:
Here is how to setup `mkdocs.yml` file to have an `include_dir` that can be used to
include generated markdown files (and the images/CSVs that they reference).
```
plugins:
- macros:
include_dir: run_for_record
```
Source code in src/trendify/api/api.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
make_it_trendy ¶
make_it_trendy(
data_product_generator: ProductGenerator | None,
input_dirs: List[Path],
output_dir: Path,
n_procs: int = 1,
dpi_static_plots: int = 500,
no_static_tables: bool = False,
no_static_xy_plots: bool = False,
no_static_histograms: bool = False,
no_grafana_dashboard: bool = False,
no_include_files: bool = False,
protocol: str = "http",
server: str = "0.0.0.0",
port: int = 8000,
data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT,
)
Maps data_product_generator over dirs_in to produce data product JSON files in those directories.
Sorts the generated data products into a nested file structure starting from dir_products.
Nested folders are generated for tags that are Tuples. Sorted data files are named according to the
directory from which they were loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_product_generator
|
ProductGenerator | None
|
A callable function that returns a list of data products given a working directory. |
required |
input_dirs
|
List[Path]
|
Directories over which to map the |
required |
output_dir
|
Path
|
Directory to which the trendify products and assets will be written. |
required |
n_procs
|
int = 1
|
Number of processes to run in parallel. If |
1
|
dpi_static_plots
|
int = 500
|
Resolution of output plots when using matplotlib
(for |
500
|
no_static_tables
|
bool
|
Suppresses static assets from the [ |
False
|
no_static_xy_plots
|
bool
|
Suppresses static assets from the
[ |
False
|
no_static_histograms
|
bool
|
Suppresses static assets from the [ |
False
|
no_grafana_dashboard
|
bool
|
Suppresses generation of Grafana dashboard JSON definition file |
False
|
no_include_files
|
bool
|
Suppresses generation of include files for importing static assets to markdown or LaTeX reports |
False
|
data_products_fname
|
str
|
File name to be used for storing generated data products |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/api.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
make_products ¶
make_products(
product_generator: Callable[[Path], DataProductCollection] | None,
data_dirs: List[Path],
n_procs: int = 1,
data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT,
)
Maps product_generator over dirs_in to produce data product JSON files in those directories.
Sorts the generated data products into a nested file structure starting from dir_products.
Nested folders are generated for tags that are Tuples. Sorted data files are named according to the
directory from which they were loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_generator
|
ProductGenerator | None
|
A callable function that returns a list of data products given a working directory. |
required |
data_dirs
|
List[Path]
|
Directories over which to map the |
required |
n_procs
|
int = 1
|
Number of processes to run in parallel. If |
1
|
data_products_fname
|
str
|
File name to be used for storing generated data products |
DATA_PRODUCTS_FNAME_DEFAULT
|
Source code in src/trendify/api/api.py
make_tables_and_figures ¶
make_tables_and_figures(
products_dir: Path,
output_dir: Path,
dpi: int = 500,
n_procs: int = 1,
no_tables: bool = False,
no_xy_plots: bool = False,
no_histograms: bool = False,
)
Makes CSV tables and creates plots (using matplotlib).
Tags will be processed in parallel and output in nested directory structure under output_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
products_dir
|
Path
|
Directory to which the sorted data products will be written |
required |
output_dir
|
Path
|
Directory to which tables and matplotlib histograms and plots will be written if
the appropriate boolean variables |
required |
n_procs
|
int = 1
|
Number of processes to run in parallel. If |
1
|
dpi
|
int = 500
|
Resolution of output plots when using matplotlib
(for |
500
|
no_tables
|
bool
|
Whether or not to collect the
[ |
False
|
no_xy_plots
|
bool
|
Whether or not to plot the [ |
False
|
no_histograms
|
bool
|
Whether or not to generate histograms of the
[ |
False
|
Source code in src/trendify/api/api.py
serve_products_to_plotly_dashboard ¶
serve_products_to_plotly_dashboard(
*dirs: Path,
title: str = "Trendify Autodash",
host: str = "127.0.0.1",
port: int = 8000,
debug: bool = False,
data_products_filename: str = DATA_PRODUCTS_FNAME_DEFAULT
)
Source code in src/trendify/api/api.py
sort_products ¶
sort_products(
data_dirs: List[Path],
output_dir: Path,
n_procs: int = 1,
data_products_fname: str = DATA_PRODUCTS_FNAME_DEFAULT,
)
Loads the tagged data products from data_dirs and sorts them (by tag) into a nested folder structure rooted at output_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dirs
|
List[Path]
|
Directories containing JSON data product files |
required |
output_dir
|
Path
|
Directory to which sorted products will be written |
required |
data_products_fname
|
str
|
File name in which the data products to be sorted are stored |
DATA_PRODUCTS_FNAME_DEFAULT
|